<template>
  <van-swipe v-if="list.length" :autoplay="300000" indicator-color="white">
    <van-swipe-item v-for="news in list" :key="news.id">
      <router-link :to="{ path: `/detail/${news.id}` }">
        <img v-lazy="news.image" />
        <div class="desc">
          <h2 class="title">{{ news.title }}</h2>
          <div class="author">{{ news.hint }}</div>
        </div>
      </router-link>
    </van-swipe-item>
  </van-swipe>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: {
      type: Array,
      default: () => []
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ .van-swipe__indicators {
  left: 100%;
  -webkit-transform: translateX(-130%);
  transform: translateX(-130%);
}
/deep/ .van-swipe__indicator {
  width: 0.12rem;
  height: 0.12rem;
}
/deep/ .van-swipe__indicator--active {
  width: 0.5rem;
  border-radius: 0.06rem;
}
img {
  width: 100%;
  display: block; // 防止img下有几像素空白
}
.desc {
  box-sizing: border-box;
  z-index: 99;
  position: absolute;
  width: 100%;
  bottom: 0;
  left: 0;
  padding: 20px;
  background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.7));
  .title {
    font-size: 21px;
    color: #fff;
    line-height: 1.5;
    margin: 0;
    margin-bottom: 10px;
    text-overflow: -o-ellipsis-lastline;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .author {
    font-size: 14px;
    color: #eee;
  }
}
</style>
